package com.example.wxminiprogram.controller;

import com.example.wxminiprogram.pojo.Result;
import com.example.wxminiprogram.service.ClassService;
import jakarta.websocket.server.PathParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@CrossOrigin
@RestController
public class ClassController {
    @Autowired
    ClassService classService;
    @GetMapping("/api/public/v1/class/l2_name_by_id")
    public Result getL1NameById(@PathParam("id") Integer id){
        return Result.success(this.classService.getL2NameById(id));
    }
    @GetMapping("/api/public/v1/class/l1")
    public Result getL1(){
        return Result.success(this.classService.getL1());
    }
    @GetMapping("/api/public/v1/class/l2")
    public Result getL2(){
        return Result.success(this.classService.getL2());
    }
    @GetMapping("/api/public/v1/class/l2_by_l1")
    public Result getL2ByL1(@PathParam("id") Integer id){
        return Result.success(this.classService.getL2ByL1(id));
    }
    @GetMapping("/api/public/v1/categories")
    public Result getL1AndL2(){
        return Result.success(classService.getL1AndL2());
    }
}
